{include 'header.tpl'}

<div class="contant">

    <div class="header">
        <div class="header_s">
            <span class="back"><a target="_blank" href="/index"><i class="iconfont fan">&#xe679;</i></a></span>
            <span class="title">确认订单</span>
            <span class="add_ads">&nbsp;</span>
            <div class="clear"></div>
        </div>
    </div>

    <div class="submint_adver">
        <div class="submit_tlt">
            <!--
             <div class="submit_newly">
              <a href="my_adressrist.html">
               <span><em><img src="images/submint_adver.png"></em>添加收货地址</span>
              </a>
             </div>-->

            <div class="section_area" id="section_area">
                <a href="/address/list?refer=/order/submit" >
                    {if $user_address}
                    <div>
                        <p class="new-tit new-p-re">
                            <span class="new-txt">{$user_address.contact}</span>
                            <span class="new-txt-rd2">{$user_address.phone}</span>
                        </p>
                        <p id="order_address">{$user_address.province} {$user_address.city} {$user_address.county} {$user_address.address}</p>
                    </div>
                    {else}
                        添加收货地址
                    {/if}
                </a>
            </div>
        </div>
    </div>
    <div class="cart_cont">
        <div class="cart_conts">
            <div class="cart_conts_tlt"><span>已选商品</span></div>
            {if $cart_list}
                {foreach from=$cart_list item=item name=foo}
            <div class="cart_contes_ct">
                <div class="cart_contes_tltl cf"><div class="cart_tity"> {$item.title}
                        {if $item.spec_list}
                            {foreach from=$item.spec_list item=i name=foo}
                                <br><span>{$i.name}:{$i.value}</span>
                            {/foreach}
                        {/if}
                    </div><span class="cart_lty">×{$item.cart_num}</span><span class="conts_tlt_ad"><em>￥{$item.price_new*$item.cart_num}</em></span>
                </div>
            </div>
                {/foreach}
            {/if}

            <div class="cart_contes_ct">
                <div class="cart_contes_tltl">配送费：由百度外卖统一专送<span class="conts_tlt_ad">￥{$money_ex.shipping}</span>
                </div>
                <!--<div class="cart_contes_tltl" style=" color:#9B9B9B;">由品牌商<em>美未央</em>进行派送</div>-->
            </div>

            {if $firstOrder or (!$firstOrder and $reduce_money > 0)}
            <div class="cart_contes_ct">
                <div class="cart_contes_tltl cf">
                    <span class="conts_ad_lf">
                        <em><img src="/mall2/images/full_cut.png"></em>{if $firstOrder}首单优惠{else}满减优惠{/if}</span>
                    <span class="conts_tlt_ad order_red">-￥{$reduce_money}</span>
                </div>
            </div>
            {/if}

            <div class="cart_contes_ct">
                <div class="cart_contes_tltl cf">
                    <div class="cart_lf_float">总计￥{$money_ex.price+$money_ex.shipping}</div>
                    <div class="cart_rg_float">
                        <span class="cart_discount">优惠￥{$reduce_money}</span>
                        实付<span class="order_red">￥{$money_ex.price+$money_ex.shipping-$reduce_money}</span>
                    </div>
                </div>
            </div>

        </div>

    </div>
    {if $firstOrder}
        {*<div class="cart_yellow"><em><img src="/mall2/images/cart_notes.png"></em>首单优惠与满减优惠不同享</div>*}
    {/if}
    <div class="cart_cont">
        <div class="cart_conts_a">
            <div class="cart_conts_tlt_a">
                <span class="beizhu_tlt" >备注</span>
                <span class="beizhu_k"><input id="beizhu" placeholder="口味，偏好等要求(140字以内)"/></span>
            </div>
        </div>

    </div>
    <form  id="form_pay" action="/order/save" method="post" autocomplete="off">
        <input type="hidden" id="paymoney" name="paymoney" value="{$money_ex.paymoney}" />
        <input type="hidden" id="aid" name="aid" value="{if $user_address}{$user_address.auto_id}{else}0{/if}" />
        <input type="hidden" id="uid" name="uid" value="{$uid}" />
        <input type="hidden" id="shipping" name="shipping" value="{$money_ex.shipping}" />
        <input type="hidden" id="rshipping" name="rshipping" value="{$money_ex.rshipping}" />
        <input type="hidden" id="shop_id" name="shop_id" value="{if $shop_info}{$shop_info.id}{else}0{/if}" />
        <input type="hidden" id="pid" name="pid" value="{$money_ex.pid}" />
        <input type="hidden" id="remark" name="remark" value="" />
        <input type="hidden" id="dis" name="dis" value="{$money_ex.distance}" />
    </form>



    <div class="status_payment"><a class="topay" href="javascript:void(0)" >微信支付</a></div>
</div>

{literal}
    <script>
        $(function(){

            $('.topay').click(function(){
                if($("#aid").val()==0){
                    $.alert('请选择收货地址');
                    return;
                }
                $('#remark').val($('#beizhu').val());
                //$('#form_pay').submit();
                $.post('/order/save',{
                    paymoney:$("#paymoney").val(),
                    aid:$("#aid").val(),
                    uid:$("#uid").val(),
                    shipping:$("#shipping").val(),
                    rshipping:$("#rshipping").val(),
                    shop_id:$("#shop_id").val(),
                    pid:$("#pid").val(),
                    remark:$("#remark").val(),
                    dis:$("#dis").val()
                },function(data){
                    if(data.code == 301||data.code == 200){
                        window.location.href=data.url;
                    }else{
                        $.alert(data.msg);
                    }
                },'json');

            });
        });
    </script>
{/literal}

{include 'footer.tpl'}